/*
 * Copyright (C) 2012 mAPPn.Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mol.market.ui;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.widget.ListAdapter;

import com.mol.market.Constants;
import com.mol.market.R;
import com.mol.market.common.widget.AppListAdapter;

/**
 * Author: Andrew.Wang
 * Date  : 12-10-10
 * Since : Version 0.9.6
 */
public class ProductListFragment extends ListFragment {


  private ListAdapter mAdapter;

//  @Override
//  public View onCreateView(LayoutInflater inflater, ViewGroup container,
//      Bundle savedInstanceState) {
//    return inflater.inflate(R.layout.common_list_view, null, false);
//  }

  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // set the list adapter
    mAdapter = createAdapter();
    setListAdapter(mAdapter);

    // make the list invisible at first
    setListShown(false);


  }


  ListAdapter createAdapter() {
    return new AppListAdapter(getActivity().getApplicationContext(),
        null,
        R.layout.common_product_list_item,
        new String[] {
            Constants.KEY_PRODUCT_ICON_URL,
            Constants.KEY_PRODUCT_NAME,
            Constants.KEY_PRODUCT_AUTHOR,
            Constants.KEY_PRODUCT_IS_STAR,
            Constants.KEY_PRODUCT_RATING,
            Constants.KEY_PRODUCT_DOWNLOAD },
        new int[] {
            R.id.iv_logo,
            R.id.tv_name,
            R.id.tv_description,
            R.id.iv_star,
            R.id.rb_app_rating,
            R.id.tv_download });
  }

}
